<!DOCTYPE html>
<html lang="zh">
<head>
    <title>申请产品 - 派后台管理系统</title>
    {include file="public/header" /}
</head>
<body>
<div class="container-fluid p-t-15">
    <div class="row">
        
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header"><h4>申请产品</h4></div>
                <div class="card-body">
                    <table id="tb_departments">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer"/}
<script type="text/javascript">
    var uid = "<?=$uid?>";
    $('#tb_departments').bootstrapTable({
        classes: 'table table-bordered table-hover table-striped',
        url: '/admin/user.user/productListLis?uid='+uid,
        method: 'post',
        dataType : 'json',        // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
        uniqueId: 'uid',
        idField: 'uid',             // 每行的唯一标识字段
        toolbar: '#toolbar',       // 工具按钮容器
        showColumns: true,         // 是否显示所有的列
        showRefresh: true,         // 是否显示刷新按钮
        responseHandler: function (res) {
            return {
                "total": res.count,
                "rows": res.data,
            };
        },
        pagination: true,
        queryParams: function(params) {
            var temp = toArrayList($(".searchForm").serializeArray());
            temp['limit'] = params.limit;
            temp['page'] = (params.offset / params.limit) + 1;
            return temp;
        },
        sidePagination: "server",
        pageNumber: 1,
        pageSize: 20,
        pageList: [20, 50, 100],
        columns: [{
            field: 'product_image',
            title: '产品头像',
            align: "center",
            formatter:function (value,row,index) {
                if (value == "") return "";
                return '<img src="'+value+'" style="width: 64px;"/>';
            },
        }, {
            field: 'product_name',
            title: '产品名称',
            align: "center"
        }, {
            field: 'create_time',
            title: '申请时间',
            align: "center"
        }],

        onEditableSave: function (field, row, oldValue, $el) {
            $.ajax({
                type: "get",
                url: "/admin/user.user/productListLis",
                data: row,
                dataType: 'jsonp',
                success: function (data, status) {
                    if (data.code == '200') {
                        // 这里的状态显示有自定义样式区分，做单行的更新
                        $('.example-table').bootstrapTable('updateRow', {index: row.uid, row: row});
                    } else {
                        alert(data.msg);
                    }
                },
                error: function () {
                    alert('修改失败，请稍后再试');
                }
            });
        },

        onLoadSuccess: function (data) {
            $("[data-toggle='tooltip']").tooltip();
        }
    });

    $("#search").click(function () {
        $('#tb_departments').bootstrapTable('refresh', {});
    });
    
</script>
</body>
</html>